<template>
  <div class="a-cardui">
    <div class="a-cardui-header">
      <h2 class="headline">{{ title }}</h2>
    </div>
    <div class="cardui-body">
      <router-link :to="`/products/detail/${info.id}`" class="card-link">
        <div class="image-wrapper">
          <img :src="info.image" :alt="title" class="card-image">
        </div>
      </router-link>
    </div>
    <div class="a-cardui-footer">
      <router-link :to="`/products/category?catId=${catId}&name=${title}`"  class="a-link-normal">
        <span class="a-truncate">{{ footerText }}</span>
      </router-link>
    </div>
  </div>
</template>

<script setup>
import {computed} from "vue";

const props = defineProps({
  title: {
    type: String,
    default: ''
  },
  catId: {
    type: String,
    default: ''
  },
  items: {
    type: Array,
    default: () => []
  },
  footerText: {
    type: String,
    default: ''
  }
})

const info = computed(() => {
  return props.items?.length ? props.items[0] : {}
})
</script>

<style lang="scss" scoped>
.a-cardui {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(15, 17, 17, 0.15);
  //height: 522px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;

  @media screen and (max-width: 768px) {
    padding: 12px;
    border-radius: 4px;
    //height: 400px;
  }

  &-header {
    margin-bottom: 12px;

    .headline {
      font-size: 21px;
      line-height: 27.3px;
      font-weight: 700;
      color: #0F1111;

      @media screen and (max-width: 768px) {
        font-size: 18px;
        line-height: 24px;
      }
    }
  }
}

.cardui-body {
  flex: 1;
  margin-bottom: 12px;
  height: 100%;

  .card-link {
    display: block;
    text-decoration: none;
    height: 100%;
  }

  .image-wrapper {
    width: 100%;
    height: 100%;
    padding-top: 0;
  }

  .card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
  }
}

.a-cardui-footer {
  margin-top: auto;

  .a-link-normal {
    color: #007185;
    text-decoration: none;
    font-size: 14px;

    &:hover {
      color: #C7511F;
      text-decoration: underline;
    }

    @media screen and (max-width: 768px) {
      font-size: 13px;
    }
  }
}
</style>

/**
 * 单图卡片组件
 * 特点：
 * - 大图展示
 * - 支持标题和底部文字
 * - 整体可点击跳转
 * - 支持自定义背景色
 * 主要用于重点活动或分类的突出展示，如游戏专区入口等
 */
